package com.ygqh.baby.model;

import java.util.Date;

import com.foxinmy.weixin4j.util.StringUtil;
import com.ygqh.baby.ao.Logistics;

public class YgLogistics {
	private Long id;

	private String orderId;

	private String expressCompany;

	private String logisticsCode;

	private String expressCode;

	private Date sendTime;

	private Date createTime;

	// ===
	private String receiver;
	private String phone;
	private String address;
	private String provinceName;
	private String cityName;
	private String areaName;

	public String getProvinceName() {
		return provinceName;
	}

	public void setProvinceName(String provinceName) {
		this.provinceName = provinceName;
	}

	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}

	public String getAreaName() {
		return areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}

	public String getReceiver() {
		return receiver;
	}

	public void setReceiver(String receiver) {
		this.receiver = receiver;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String findLogisticsCode(String expressCompany) {
		Logistics[] logistics = Logistics.values();
		for (Logistics item : logistics) {
			if (item.getTitle().equals(expressCompany)) {
				return item.name();
			}
		}

		return null;

	}

	public YgLogistics() {
		super();
	}

	public YgLogistics(String orderId, String expressCompany, String logisticsCode, String expressCode, Date sendTime, Date createTime) {
		super();
		this.orderId = orderId;
		this.expressCompany = expressCompany;
		this.logisticsCode = StringUtil.isNotBlank(logisticsCode) ? logisticsCode : this.findLogisticsCode(expressCompany);
		this.expressCode = expressCode;
		this.sendTime = sendTime;
		this.createTime = createTime;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId == null ? null : orderId.trim();
	}

	public String getExpressCompany() {
		return expressCompany;
	}

	public void setExpressCompany(String expressCompany) {
		this.expressCompany = expressCompany == null ? null : expressCompany.trim();
	}

	public String getLogisticsCode() {
		return logisticsCode;
	}

	public void setLogisticsCode(String logisticsCode) {
		this.logisticsCode = logisticsCode == null ? null : logisticsCode.trim();
	}

	public String getExpressCode() {
		return expressCode;
	}

	public void setExpressCode(String expressCode) {
		this.expressCode = expressCode == null ? null : expressCode.trim();
	}

	public Date getSendTime() {
		return sendTime;
	}

	public void setSendTime(Date sendTime) {
		this.sendTime = sendTime;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getAddr() {
		return provinceName + " " + areaName + " " + cityName + " " + address;

	}
}